package client.comm.baoding.ui.vm

import android.app.Application
import androidx.lifecycle.MutableLiveData
import client.comm.commlib.network.data.JsonResult
import client.comm.baoding.api.bean.TdBean
import client.comm.baoding.ui.viewmodel.MiddleVm

class TdViewModel(app: Application) : MiddleVm(app) {

    val isOneLoading = MutableLiveData<Boolean>(false)
    val isTwoLoading = MutableLiveData<Boolean>(false)
    val pageOne = MutableLiveData<Int>(0)
    val pageTwo = MutableLiveData<Int>(0)
//    val status = MutableLiveData<Int>(1)
    val callOne = MutableLiveData<JsonResult<TdBean>>()
    val callTwo = MutableLiveData<JsonResult<TdBean>>()

    val bean = MutableLiveData<String>()

    fun get_user_team() {
        if (isOneLoading.value!!)
            return
        hold({
            server.get_user_team(bean.value!!, pageOne.value!!)
        }, {
            isOneLoading.value = true
            pageOne.value = pageOne.value!! + 1
        }, {
            callOne.value = it
        }, complete = {
            isOneLoading.value = false
        })
    }

    fun get_user_team1() {
        if (isTwoLoading.value!!)
            return
        hold({
            server.get_user_team1(bean.value!!, pageTwo.value!!,1)//,status.value!!
        }, {
            isTwoLoading.value = true
            pageTwo.value = pageTwo.value!! + 1
        }, {
            callTwo.value = it
        }, complete = {
            isTwoLoading.value = false
        })
    }
}